#ifndef __C_STEGANOGRAPHY__
#define __C_STEGANOGRAPHY__

#include "trie.h"

#define JPEG_START 0xFFD8       // Starting two bytes of JPEG file
#define DQT_START  0xFFDB
#define START_OF_FRAME_0    0xFFC0
#define DRI_MARKER          0xFFDD
#define DHT_START  0xFFC4
#define JPEG_SOS   0xFFDA         // Starting two bytes of JPEG IMG data
#define JPEG_END   0xFFD9         // Signals the end of JPEG file

#define EOB 0 // End of line value, says to stop processing DC or AC of MCU
#define ZRL 0xF0 // Signifies 16 0-value coeficients
#define MARKER_LENGTH 2  // length of the marker of a JPEG segment

// Constants for ids of specific color values:
#define Y_ID  1   // luminance
#define CB_ID 2  // blue chrominance
#define CR_ID 3  // red chrominance


/* 
 * struct for holding data for jpeg
 * 
 * Takes advantage that Color ids of Y, Cr, and Cb are 1, 2, and 3 respectively
 */
typedef struct jpegStats {
    unsigned short restartInterval;  // number of MCUs before a restart token
                                     // is encountered
    unsigned int mcuCount;           // number of MCUs in file
    unsigned short colorCounts[3];   // color_id - 1 ---> number of color 
                                     //values with that ID in MCU
    unsigned int totalColorCounts;  // sum of all elements in colorCounts
    // color_id - 1 ---> corresponding DC and AC tables
    dhtTrie* dcHuffmanTables[3];
    dhtTrie* acHuffmanTables[3];
} jpegStats;

int checkJpgCapacity(const char* jpgPath);

// 将信息隐藏到jpeg文件当中
int hideMessageToJpg(const char* srcJpg, const char* targetJpg, char* message); 

// 调用者需要自己释放读出的message
char* newMessageFromJpg(const char* jpgFile);

// 调用者需要自己释放读出的message
char* newMessageFromJpgBytes(char* jpgBytes, int jpgSize);

// 将隐藏信息读入msgBuffer中
int getMessageFromJpgBytes(char* jpgBytes, int jpgSize, char *msgBuffer, int bufSize);


#endif
